From 4721eed0a15521af7feec7ef9e7c2a6893238cfd Mon Sep 17 00:00:00 2001 From: tsteven4 Date: Mon, 24 Feb 2014 01:48:06 +0000 Subject: [PATCH] QString cleanup for googledir, transform. --- gpsbabel/googledir.cc | 24 +++++++++--------------- gpsbabel/transform.cc | 2 +- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/gpsbabel/googledir.cc b/gpsbabel/googledir.cc index 734104c11..8f591774c 100644 --- a/gpsbabel/googledir.cc +++ b/gpsbabel/googledir.cc @@ -65,18 +65,18 @@ goog_instr(xg_string args, const QXmlStreamAttributes*) static int goog_step = 0; static long -decode_goog64(char** str) +decode_goog64(const QByteArray& str, int& pos) { long result = 0; unsigned char c = 0; unsigned char shift = 0; - if (!(**str)) { + if (pos >= str.size()) { return 0; } do { - c = (unsigned char)(*(*str)++)-'?'; + c = (unsigned char)str.at(pos++)-'?'; result |= (c & 31)<rte_desc = "Overview"; } else { goog_step++; - xasprintf(&routehead->rte_name, "step%03d", goog_step); + routehead->rte_name = QString("step%1").arg(goog_step, 3, 10, QChar('0')); if (instructions == NULL) { - xasprintf(&routehead->rte_desc, "Step %d", goog_step); + routehead->rte_desc = QString("Step %1").arg(goog_step); } else { utf_string utf; utf.is_html = 1; @@ -121,21 +119,17 @@ goog_poly_e(xg_string args, const QXmlStreamAttributes*) } route_add_head(routehead); - while (str && *str) { - lat += decode_goog64(&str); - lon += decode_goog64(&str); + for (int qbpos=0; qbpos < qbstr.size();) { + lat += decode_goog64(qbstr, qbpos); + lon += decode_goog64(qbstr, qbpos); { Waypoint* wpt_tmp = new Waypoint; wpt_tmp->latitude = lat / 100000.0; wpt_tmp->longitude = lon / 100000.0; - /* FIXME no need for name - xsaprintf(wpt_tmp->shortname, "\\%5.5x", serial++); - */ route_add_wpt(routehead, wpt_tmp); } } -xfree(ostr); encoded_points = QString(); instructions = QString(); } diff --git a/gpsbabel/transform.cc b/gpsbabel/transform.cc index 8d6302fd0..9eb7644f2 100644 --- a/gpsbabel/transform.cc +++ b/gpsbabel/transform.cc @@ -114,7 +114,7 @@ transform_rte_disp_hdr_cb(const route_head* rte) current_trk = route_head_alloc(); track_add_head(current_trk); if (!rte->rte_name.isEmpty()) { - xasprintf(¤t_trk->rte_desc, "Generated from route %s", CSTRc(rte->rte_name)); + current_trk->rte_desc = QString("Generated from route %1").arg(rte->rte_name); current_trk->rte_name = rte->rte_name; /* name the new trk */ } } -- 2.30.2